//
//  StructAndClassViewController.swift
//  test_swift
//
//  Created by fangyuan ding on 2021/5/31.
//

import UIKit

class StructAndClassViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        struct Date {
            var year : Int
            var month : Int
            var day : Int
            
        }
        var date = Date(year: 2020, month: 07, day: 24)
        print(date)
         //这里只是定义了Date结构体，但是直接可以调用Date(year: 2020, month: 07, day: 24)
        
        // 值类型赋值 ；String、Array、Dictionary、Set也是结构体类型，所以他们也属于值类型
        struct Point {
            var x : Int = 0
            var y : Int
            
        }
        func test(){
            let p1 : Point = Point(x: 10, y: 20)
            var p2 : Point = p1
            
            p2.x = 22
            p2.y = 33
            
            print(p1)//Point(x: 10, y: 20)
        }


        let s1 = "jack"
        var s2 = s1
        s2.append("_hi")
        print(s1)// jack
        print(s2)//jack_hi
        
        
        struct PersonObj {
            enum sex : String {
                case man = "1", woman = "2"
            }
            enum nation : Int {
                case hanzu = 1 , manzu = 2 , weiwuerzu = 3
            }
        }

        print(PersonObj.sex.man.rawValue)

        var sextype = PersonObj.sex.man
        sextype = .woman

    }
    


}
